home *** CD-ROM | disk | FTP | other *** search
- Path: news.ner.bbnplanet.net!forest!groy
- From: groy@forest.drew.edu (I can't think of a nickname)
- Newsgroups: comp.lang.c
- Subject: HELP!!! -very important-- #3
- Message-ID: <1996Mar21.001800.138165@forest>
- Date: 21 Mar 96 00:18:00 EST
- Organization: Drew University
-
- This is the last one (for a while nayway.. ) I promise.. ;)
- I am trying to write a program that will take in any input.. and count up
- the numbers of characters... words and lines... it just doesn't want to
- work... help??
-
- #include<stdio.h>
- #include<ctype.h>
-
- int main() {
- int words = 0; /* number of words */
- int lines = 0; /* number of lines */
- int characters = 0; /* number of characters */
- char input; /* the area of input */
- int check_letter(char input); /* function that will check characters */
- int check_lines(char input); /* function that will check lines */
- int whitespace = 1;
-
-
- printf("type in any group of words, lines, characters that you wish");
- printf("\nthen the computer will display the amount of words, lines");
- printf("\nand characters (ignoring any white-space) that you may\n");
- printf("type in. <<press cntrl-d when done>> \n");
-
- while ((scanf("%c",&input)) != EOF)
- {
- characters += isalnum(input);
- lines = check_lines(input) + lines;
- if (isspace(input)) {
- whitespace++;
- }
- else if (isalnum(input) && (whitespace > 0)) {
- whitespace = 0;
- words++; }
- }
-
- printf("the number of lines is: %i\n", lines);
- printf("the number of words is: %i\n", words);
- printf("the number of characters is: %i\n", characters);
-
- } /* end of main */
-
- int check_letter(char input) {
- return isalnum(input);
- } /*end of check_letter */
- int check_lines(char input) {
- return iscntrl(input);;
- } /* end of check_lines */
-
-
-
- I just noticed something... the { and } are the forward brackets and
- reverse brackets.. I deleted them from the last post... if they look
- correct to you then fine... if not.. I hope you can read how the last post
- went... thecomments should help..... aahhhhhhh i am breaking doen here...
- please help
-
-
-
- Greg Roy
- groy@drew.edu
-